#include "canig.h"
#include "ui_canig.h"
//outside initialization instance ptr
canig* canig::instance = nullptr;
canig::canig(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::canig)
{
    ui->setupUi(this);
}

canig::~canig()
{
    delete ui;
}
//make it mutex
canig* canig::getInstance()
{
    //multi thread to access it ,may cause compete.
    static QMutex mutex;
    if(!instance)
    {
        //make it to lock to solve thread saftey
        QMutexLocker locker(&mutex);
        if(!instance)
        {
            qDebug()<<"new canig";
            instance = new canig;
        }
    }
    return instance;
}

void canig::on_pushButtonopenIG_clicked()
{
    CanIGBus *instance = CanIGBus::getInstance();
    instance->showMaximized();
}

